package persistence;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;

public class FileStorageRegistry 
{

	//member variables
	private String EventsFileName = "events.txt";
	private String HallsFileName = "halls.txt";
	private static FileStorageRegistry Instance;
	
	private FileStorageRegistry()
	{
		
	}
	
	public static FileStorageRegistry GetInstance()
	{
		if(Instance == null)
		{
			Instance = new FileStorageRegistry();
			return Instance;
		}
		
		else
		{
			return Instance;
		}
	}
	
	
	public void CheckFilesExist(String FileName)
	{
		File events = new File(FileName);

        try 
        {
        	BufferedReader reader = new BufferedReader(new FileReader(FileName));
        	
        }
        
        catch(FileNotFoundException g)
        {
        	
        	try
        	{
        		System.out.println("File Stoarge Does not Exist, so will create files for persistence Storage.");
        		File f;
        	
        		f=new File(FileName);
        	 
        		if(!f.exists())
        		{
        			f.createNewFile();
        		}
        	}
        	
        	catch(Exception h)
        	{
        		System.out.println("Error Creating new Storage");
        	}
        	
        }
        
        catch(Exception f)
        {
        	System.out.println("Some other File Error..");
        }

	}

	public String getEventsFileName() {
		return EventsFileName;
	}

	public void setEventsFileName(String eventsFileName) {
		EventsFileName = eventsFileName;
	}

	public String getHallsFileName() {
		return HallsFileName;
	}

	public void setHallsFileName(String hallsFileName) {
		HallsFileName = hallsFileName;
	}
	
	
}
